# PHP mysqli_options() Function

PHP MySQLi Reference

## Example

Open a new connection to the MySQL server:

<?php
$con=mysqli_init();
if (!$con)
{
die("mysqli_init failed");
}
mysqli_options($con,MYSQLI_READ_DEFAULT_FILE,"myfile.cnf");
if (!mysqli_real_connect($con,"localhost","my_user","my_password","my_db"))
{
die("Connect Error: " . mysqli_connect_error());
}
mysqli_close($con);
?>

## Definition and Usage

The mysqli_options() function sets extra connect options and affect behavior for a connection.

The mysqli_options() function can be called several times to set several options.

Note: The mysqli_options() function should be called after mysqli_init() and before mysqli_real_connect().

## Syntax

mysqli_options(connection,option,value);

Parameter | Description
--- | ---
connection | Required. Specifies the MySQL connection to use

option

Required. Specifies the option to set. Can be one of the following values:

- MYSQLI_OPT_CONNECT_TIMEOUT - connection timout in seconds
- MYSQLI_OPT_LOCAL_INFILE - enable/disable use of LOAD LOCAL INFILE
- MYSQLI_INIT_COMMAND - command to execute after connecting to MySQL server
- MYSQLI_READ_DEFAULT_FILE - read options from named file instead of my.cnf
- MYSQLI_READ_DEFAULT_GROUP - read options from named group from my.cnf or the file specified in MYSQLI_READ_DEFAULT_FILE
- MYSQLI_SERVER_PUBLIC_KEY - RSA public key file used with SHA-256 based authentication

value | Required. Specifies the value for the option

## Technical Details

Return Value: | TRUE on success. FALSE on failure
PHP Version: | 5+
Changelog: | The MYSQLI_SERVER_PUBLIC_KEY option was added in PHP 5.5

PHP MySQLi Reference

### WEB HOSTING

UK Reseller Hosting

### WEB BUILDING

FREE Website BUILDER Free HTML5 Templates

### W3SCHOOLS EXAMS

HTML, CSS, JavaScript, PHP, jQuery, XML, and ASP Certifications

### SHARE THIS PAGE

### Color Picker

### HTML/CSS

HTML Tutorial HTML5 Tutorial CSS Tutorial CSS3 Tutorial Bootstrap Tutorial

### JavaScript

JavaScript Tutorial jQuery Tutorial jQuery Mobile Tutorial AngularJS Tutorial AJAX Tutorial JSON Tutorial

### Graphics

Canvas Tutorial SVG Tutorial Google Maps Tutorial

### Server Side

SQL Tutorial PHP Tutorial ASP Tutorial ASP.NET Tutorial VBScript Tutorial AppML Tutorial

### Web

Web Building Web Statistics Web Certification

### XML

XML Tutorial DTD Tutorial Schema Tutorial XML DOM Tutorial XPath Tutorial XSLT Tutorial XQuery Tutorial XSL-FO Tutorial RSS Tutorial WSDL Tutorial

### HTML/CSS

HTML Tag Reference HTML Event Reference HTML Color Reference CSS 1,2,3 Reference Bootstrap Reference

### JavaScript

JavaScript Reference HTML DOM Reference jQuery Reference jQuery Mobile Reference Google Maps Reference

### Server Side

PHP Reference SQL Reference ASP Reference VBScript Reference Razor Reference ASP.NET Reference

### XML

XML DOM Reference XSLT Reference XSL-FO Reference XPath Reference XQuery Reference Schema Reference RSS Reference SVG Reference

### HTML Charsets

HTML Character Sets HTML ASCII HTML ANSI HTML Windows-1252 HTML ISO-8859-1 HTML Symbols HTML UTF-8

### HTML/CSS

HTML Examples CSS Examples

### Browser Scripting

JavaScript Examples HTML DOM Examples jQuery Examples jQuery Mobile Examples AngularJS Examples AJAX Examples

### Server Scripting

PHP Examples ASP Examples VBScript Examples Razor Examples .NET Examples

### XML Languages

XML Examples DTD Examples XML DOM Examples XSL Examples XSLT Examples XPath Examples XQuery Examples Schema Examples RSS Examples SVG Examples